Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

joomla3: allow importing drafts #272

Closed
wants to merge 1 commit into from

Conversation

GreatEmerald
Copy link
Contributor

Fix for issue #268. Also some whitespace cleanup (tabs and spaces where mixed beforehand).

This is a bit of a behaviour change in that it now only imports published articles by default, as opposed to both published and archived ones. But it can be rerun several times for several publishing states, so it shouldn't be much of an issue.

A new "state" parameter is added to select posts based on their publishing state. By default only published articles are imported, and unpublished articles are imported into the _drafts directory.
@@ -16,6 +16,7 @@ def self.specify_options(c)
c.option 'host', '--host', 'Database host name'
c.option 'category', '--category', 'ID of the category'
c.option 'prefix', '--prefix', 'Table prefix name'
c.option 'state', '--state', 'Which publishing state to select. 0: unpublished, 1: published, 2: archived (default: 1)'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to change to state STATE right after c.option so the parser knows it takes an arg. Surprised the ones above aren't like that... Whoops!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I would consider using the full words here – it's much more readable to use --state unpublished than --state 0.

@parkr
Copy link
Member

parkr commented Aug 29, 2016

Thank you, @GreatEmerald! I took a look through and left a few comments. Let me know what you think! ✨

@GreatEmerald
Copy link
Contributor Author

Yeap, that sounds good generally. I was hoping someone with more Ruby knowledge would look at it ;)

I don't really get your first comment: what should all those options look like, then?

While I'm at it, I was also wondering if there's a good way to deal with https://github.com/jekyll/jekyll-import/blob/master/lib/jekyll-import/importers/joomla3.rb#L50 since it just filters out the "uncategorised" category, which may very well be useful to import; one can run the tool twice, once with category ID specifically set to 2, but, well, as you mentioned, that's pretty cryptic. Maybe an option like --no-category as the opposite for --category would be a better idea, but I don't really know how to make them mutually exclusive in a nice way... The same general method could be used for the drafts as well, allow excluding them instead of having to run the tool several times...

@GreatEmerald
Copy link
Contributor Author

Oh, and when I used the tool I noticed that some of the articles didn't actually get imported at all, despite me rerunning the tool four times to make sure nothing is exluded. I'll try to find out why.

@parkr
Copy link
Member

parkr commented Sep 18, 2016

Oh, and when I used the tool I noticed that some of the articles didn't actually get imported at all, despite me rerunning the tool four times to make sure nothing is exluded. I'll try to find out why.

Were you able to figure out this bug?

Maybe an option like --no-category as the opposite for --category would be a better idea, but I don't really know how to make them mutually exclusive in a nice way... The same general method could be used for the drafts as well, allow excluding them instead of having to run the tool several times...

Let's think about the general use case for importing your posts into Jekyll. You probably want every piece of content you produces, including unpublished and archived. The only things I wouldn't care about are trashed items. When I run the importer, I'd like all of my draft, published, unpublished, and archived posts imported unless I specify. Perhaps the best thing is to default to importing all and only using the --state flag if I want a subset of that.

$ jekyll import joomla3 
# Imports *everything* by default except trashed items
$ jekyll import joomla3 --states unpublished,published
# Imports posts with `unpublished` and `published` states only

What do you think?

@GreatEmerald
Copy link
Contributor Author

Yes, I double-checked and it turns out that it did import everything correctly after all, it was just me searching for one term when the article was named another...

And yes, that is indeed reasonable and how I expected the importer to work as well. The reason why I also made it initially only import one is because it makes code simpler, but the enum ("hash") idea would indeed nicely solve the issue to allow for importing all by default. As for the "uncategorised" category, indeed, I don't really know why the original author thought that it should be excluded by default. I'd rather it was included by default too.

@DirtyF
Copy link
Member

DirtyF commented Dec 21, 2018

Closing after a long period of inactivity, feel free to re-open to fix remaining conflicts and get this merged.

@DirtyF DirtyF closed this Dec 21, 2018
@jekyll jekyll locked and limited conversation to collaborators Dec 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants